home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / JAVA Utilities / JProxy 1.1.0 / customers / buy-customer-upgrade.jsp < prev    next >
Encoding:
Text File  |  2003-04-29  |  10.3 KB  |  270 lines

  1. <%@ page language="java" import="
  2.     java.util.*,
  3.     com.jproxy.site.mbeans.JMXInvocator,
  4.     com.jproxy.site.mbeans.config.*,
  5.     com.jproxy.site.ejbeans.interfaces.ISaleFormula,
  6.     com.jproxy.site.ejbeans.interfaces.IProduct,
  7.     com.jproxy.site.*"
  8. %>
  9.  
  10. <jsp:useBean id="buycustomers" scope="request" class="com.jproxy.site.customers.Buy"/>
  11. <%
  12. buycustomers.request(pageContext);
  13. buycustomers.ses.setNewHit(pageContext, "hits", "Customer Buy Page", null);
  14. %>
  15.  
  16. <%
  17. int licenses = buycustomers.purchasedLicenses;
  18. int purchasedLicenses = 0;
  19. int support_licenses = 0;
  20. String productName = "";
  21.  
  22. String productID = buycustomers.getParameter("productid").trim();
  23. if(buycustomers.getParameter("licenses").trim().length()>0)
  24.     licenses = new Integer(buycustomers.getParameter("licenses")).intValue();
  25. if(buycustomers.getParameter("purchased-licenses").length()>0)
  26.     purchasedLicenses = new Integer(buycustomers.getParameter("purchased-licenses")).intValue();
  27. if(buycustomers.getParameter("support_licenses").length()>0)
  28.     support_licenses = new Integer(buycustomers.getParameter("support_licenses")).intValue();
  29.  
  30. // find out the number of licenses requested
  31. if (licenses <= 0)
  32.     licenses = 1;
  33. // find out the number of licenses requested
  34. if(support_licenses < 0)
  35.     support_licenses = 1;
  36.  
  37. if(productID.length()>0)
  38.     productName = buycustomers.product.getProductName();
  39. else
  40. {
  41. %>
  42.     <span class="h9Verdana">Failed to obtain Product Id!
  43.     Please report this error to <a class="h8VerdanaBold" href="mailto:postmaster@jproxy.com">postmaster@jproxy.com</a></span>
  44. <%
  45.     return;
  46. }
  47.  
  48. String customerName = buycustomers.customer.getCustomerName();
  49. String host = "http://"+request.getServerName()+":"+request.getServerPort();
  50.  
  51. boolean isDisabled = false;
  52. ISaleFormula formula = (ISaleFormula)buycustomers.formulas.elementAt(0);
  53.  
  54. int firstLicensePrice = formula.getFirstLicense();
  55. int additionalLicensePrice = formula.getAdditionalLicense();
  56. System.out.println("FIRST LICENS PRICE "+firstLicensePrice);
  57. System.out.println("ADDITIONAL LICENS PRICE "+additionalLicensePrice);
  58. //if(purchasedLicenses>0)
  59. //    firstLicensePrice = additionalLicensePrice;
  60.  
  61. int customerId = 0;
  62. int invoice = 0;
  63.  
  64. int    StandardSupportDuration = 30;
  65. int    AdvancedSupportDuration = 90;
  66.  
  67. // calculate the TOTAL AMOUNT based on the number of licenses and the pricing model
  68. double lic_cost = firstLicensePrice * buycustomers.formula.getDiscount();
  69. lic_cost += (licenses-1) * additionalLicensePrice * buycustomers.formula.getDiscount();
  70. lic_cost = lic_cost*buycustomers.formula.getUpgrade();
  71. double sup_cost = lic_cost * buycustomers.formula.getSupport() * support_licenses;
  72.  
  73. if(request.getParameter("submit_recalculate")!=null)
  74. {
  75. }
  76. if(request.getParameter("submit_purchase")!=null && request.getParameter("error")==null)
  77. {
  78. %>
  79.     <jsp:forward page="purchase.jsp"/>
  80. <%
  81. }
  82. %>
  83.   <!-- HEADER -->
  84.   <jsp:include page="header.jsp" flush="true">
  85.     <jsp:param name="name" value="ePortal - Upgrade Licenses and Technical Support"/>
  86.     <jsp:param name="pageId" value="buy"/>
  87.   </jsp:include>
  88.  
  89. <!-- MAIN PANEL -->
  90. <%
  91. ConfigMBean mbean = (ConfigMBean)JMXInvocator.getMBean("JProxy:service=JProxyConfigMBean", ConfigMBean.class);
  92. //String productName = mbean.get("com.jproxy.proxy.name") + " " + mbean.get("com.jproxy.proxy.version");
  93. String invoiceStr = mbean.get("com.jproxy.commerce.invoice");
  94. try{
  95.     invoice = Integer.parseInt(invoiceStr);
  96. }
  97. catch(Exception e){
  98.     invoice = 15;
  99. }
  100. %>
  101.  
  102. <%
  103. String sProductDescr;
  104. %>
  105. <br>
  106.   <table class="h8Verdana" cellpadding="5" width="100%" border="0">
  107. <!-- Prolog -->
  108.     <tr>
  109.      <td>
  110.          You're about to purchase <span class="h8VerdanaBold"><%=buycustomers.product.getProductName()%></span> licenses.
  111.          Please enter the desired number of software license and the number of
  112.          <a target='home' href="/main/support.jsp#advanced">Advanced Support Packages</a>, which are
  113.          optional. The software comes with the <a target='home' href="/main/support.jsp#standard">Standard Support Package</a>
  114.          free of charge.
  115.          <p>
  116.          If you elect to purchase Advanced Support Package
  117.          please select the number of the packages you would like to purchase. If you would like to get longer
  118.          support please increase the number of support packages to get the desired support duration.
  119.          <p>
  120.          Once yo've entered desired number of licenses and support packages, please press the <Recalcualte> button
  121.          to get the updated price.
  122.          <p>
  123.     </td>
  124.         </tr>
  125.     <tr>
  126.      <td>
  127.              <form method="get" action="buy.jsp">
  128.         <table class="h9Verdana" width="100%" border="0" bgcolor="9c9cff" cellpadding="1" cellspacing="0">
  129.          <tr><td>
  130.            <%=productName%>
  131.          </td></tr>
  132.          <tr><td>
  133.              <table class="h9Verdana" width="100%"  border="0" bgcolor="white" cellpadding="5" cellspacing="3" >
  134.               <tr>
  135.                <td align="left" width="65%" bgcolor="#f6f6f6">
  136.                              Number of Licenses:
  137.                              <INPUT TYPE=HIDDEN NAME="customer-id" VALUE="<%=buycustomers.customerID%>">
  138.                              </td>
  139.                <td align="left" bgcolor="#f3f8ff">
  140.                              <input type="input" name="licenses" READONLY value="<%=licenses%>" size="3">
  141.                            </td>
  142.                            <td align="right" width="35%" bgcolor="#f3f8ff">
  143.                              Subtotal: <input type="text" name="total" READONLY value="$<%=lic_cost%>" size="10">
  144.                </td>
  145.               </tr>
  146.             </table>
  147.           </td></tr>
  148.   <!-- begin title -->
  149.           <tr><td>
  150.                   Advanced Support Package
  151.           </td></tr>
  152.   <!-- begin prices -->
  153.           <tr><td>
  154.              <table class="h9Verdana" width="100%" border="0" bgcolor="white" cellpadding="5" cellspacing="3" >
  155.               <tr>
  156.                <td align="left" width="65%" bgcolor="#f6f6f6">
  157.                  Number of Support Cycles:
  158.                            </td>
  159.                <td align="left" bgcolor="#f3f8ff">
  160.                  <input type="input" name="support_licenses" value="<%=support_licenses%>" size="3">
  161.                            </td>
  162.                            <td align="right" width="35%" bgcolor="#f3f8ff">
  163.                              Subtotal: <input type="text" name="total" READONLY value="$<%=sup_cost%>" size="10">
  164.                </td>
  165.               </tr>
  166.              </table>
  167.           </td></tr>
  168.   <!-- begin prices -->
  169.           <tr><td>
  170.              <table class="h9Verdana" width="100%" border="0" bgcolor="white" cellpadding="5" cellspacing="3" >
  171.               <tr>
  172.                            <td align="left" width="68%" bgcolor="#f3f8ff">
  173.                              <INPUT TYPE=SUBMIT NAME=submit_recalculate WIDTH="20" VALUE="Recalculate">
  174.                              <INPUT TYPE=HIDDEN NAME="productid" VALUE="<%=buycustomers.product.getID()%>">
  175.                              <INPUT TYPE=HIDDEN NAME="purchased-licenses" VALUE="<%=purchasedLicenses%>">
  176.                              <INPUT TYPE=HIDDEN NAME="is-upgrade" VALUE="true">
  177.                            </td>
  178.                            <td align="right" width="32%"bgcolor="#f3f8ff">
  179.                              Grand Total: <input type="text" name="total" READONLY value="$<%=lic_cost + sup_cost%>" size="10">
  180.                            </td>
  181.               </tr>
  182.             </table>
  183.           </td></tr>
  184.         </td></tr>
  185.               </table>
  186.             </form>
  187.            <table class="h9Verdana" width="100%" border="0" bgcolor="white" cellpadding="5" cellspacing="3" >
  188.             <tr>
  189.              <td align="left" bgcolor="#f3f8ff">
  190.         <%
  191.         if (support_licenses == 0)
  192.         {
  193.             sProductDescr = productName + " with Standard Support Package for " +
  194.                 Integer.toString(StandardSupportDuration) + " days";
  195.         }
  196.         else
  197.         {
  198.             sProductDescr = productName + " and Advanced Support Package for " +
  199.                 Integer.toString(support_licenses * AdvancedSupportDuration) + " days";
  200.         }
  201.         %>
  202.                <span class="h8Verdana">Your selection is: <%=licenses%> license(s) for <%=sProductDescr%>.</span>
  203.              </td>
  204.             </tr>
  205.              <tr>
  206.                <td class="h8Verdana" align="left">
  207.                   Before submitting your purchase order please read our <a class="h8VerdanaBold" target="_blank" href="<%=JSPRes.path%>/main/resources/docs/eula.pdf">License agreement</a></span>
  208.                   and also review our <a class="h8VerdanaBold" target="_blank" href="/main/content/refundpolicy.html">refund policy</a>
  209.                </td>
  210.              </tr>
  211.              <tr>
  212.                <td align="right">
  213.             <!-- begin purchase button -->
  214.                   <%
  215.                   String headerHTML = "<font size=30 color=#6331CE>JProxy</font>";
  216.                           headerHTML += "<font size=10 color=#9C00FF>.com</font>";
  217.                   String footerHTML = "<font size=2><em>Copyright 2001-2002, JProxy</em></font>";
  218.                   %>
  219.  
  220.     <%
  221.         sProductDescr = "Licenses # : "+licenses+" ($"+lic_cost+")";
  222.         if(support_licenses == 0)
  223.         {
  224.             sProductDescr += "<br>"+productName + " and Standard Support Package for " +
  225.                 Integer.toString(StandardSupportDuration) + " days : $"+sup_cost;
  226.         }
  227.         else
  228.         {
  229.             sProductDescr += "<br>"+productName + " and Advanced Support Package for " +
  230.                 Integer.toString(support_licenses * AdvancedSupportDuration) + " days : $"+sup_cost;
  231.         }
  232.     %>
  233.             <!-- begin purchase button -->
  234.                      <FORM METHOD=POST ACTION="https://secure.authorize.net/gateway/transact.dll">
  235.                        <INPUT TYPE=HIDDEN NAME="number_of_licenses" VALUE="<%=licenses%>">
  236.                     <INPUT TYPE=HIDDEN NAME="customer-id" VALUE="<%=buycustomers.customerID%>">
  237.                     <INPUT TYPE=HIDDEN NAME="parent-id" VALUE="<%=buycustomers.ses.getLogin().getID()%>">
  238.                     <INPUT TYPE=HIDDEN NAME="is-upgrade" VALUE="true">
  239.                        <INPUT TYPE=HIDDEN NAME="x_amount" VALUE="<%=lic_cost + sup_cost%>">
  240.                        <INPUT TYPE=HIDDEN NAME="x_Version" VALUE="3.0">
  241.                        <INPUT TYPE=HIDDEN NAME="x_Login" VALUE="jproxyllc">
  242.                        <INPUT TYPE=HIDDEN NAME="x_Show_Form" VALUE="PAYMENT_FORM">
  243.                        <INPUT TYPE=HIDDEN NAME="x_Cust_ID" VALUE="<%=customerId%>">
  244.                        <INPUT TYPE=HIDDEN NAME="x_Invoice_Num" VALUE="<%=invoice%>">
  245.                        <INPUT TYPE=HIDDEN NAME="x_Description" VALUE="<%=sProductDescr%>">
  246.                        <!-- INPUT TYPE=HIDDEN NAME="x_Logo_URL" VALUE="http://jproxy.com/main/resources/jproxy.gif" -->
  247.                        <INPUT TYPE=HIDDEN NAME="x_Header_HTML_Payment_Form" VALUE="<%=headerHTML%>">
  248.                        <INPUT TYPE=HIDDEN NAME="x_Footer_HTML_Payment_Form" VALUE="<%=footerHTML%>">
  249.                        <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_Method" VALUE="GET">
  250.                        <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_Text" VALUE="Click here to continue">
  251.                        <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_URL" VALUE="<%=host%>/main/customers/purchase.jsp;jsessionid=<%=request.getSession().getId()%>">
  252.                        <INPUT TYPE=SUBMIT NAME=submit_purchase WIDTH="20" VALUE="Purchase">
  253.                        <INPUT TYPE=HIDDEN NAME="productid" VALUE="<%=buycustomers.product.getID()%>">
  254.                       </FORM>
  255.                </td>
  256.         </tr>
  257.       </table>
  258.      </td>
  259.     </tr>
  260.  
  261.     <tr>
  262.      <td>
  263.            <p>
  264.      </td>
  265.     </tr>
  266.   </table>
  267.  
  268. <!-- FOOTER -->
  269. <jsp:include page="footer.jsp" flush="true"/>
  270.